package com.CTAtracker.android.Adapters;

import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.FrameLayout;
import android.widget.TextView;

import com.CTAtracker.android.R;
import com.CTAtracker.android.Models.Station;

public class SeveralStationAdapter extends ArrayAdapter<Station> {

	/**
	 * The layout to inflate
	 */
	private LayoutInflater _layoutInflater = null;
	/**
	 * The Id of the resource to inflate
	 */
	private int _resourceId = 0;
	/**
	 * The List of the Lines to adapt to the view
	 */
	private ArrayList<Station> _listStation;
	
	
	public SeveralStationAdapter(Context context, int resourceId,List<Station> objects) {
		super(context, resourceId, objects);
		_layoutInflater = LayoutInflater.from(context);
		_resourceId = resourceId;
		_listStation = (ArrayList<Station>) objects; 
	}

	/**
	 * This method is called every time we want to display the view
	 */
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {

		final Station station = _listStation.get(position);
		convertView = _layoutInflater.inflate(_resourceId, parent, false);
		
		TextView textView = (TextView) convertView.findViewById(R.id.severalStationNameStop);
		FrameLayout frameLayout = (FrameLayout) convertView.findViewById(R.id.severalStationFrameColor);
		
		textView.setText(station.get_color().getStationName());
		frameLayout.setBackgroundColor(Color.parseColor(station.get_color().toString()));

		return convertView;
	}
	
}
